﻿using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Vidh.SimplyToDo.Controllers.ViewModels
{
    public class RegisterModel : BaseModel
    {
        public RegisterModel()
        {
        }

        public int ID { get; set; }

        [Required]
        [Display(Name = "First Name")]
        public string FirstName { get; set; }

        [Required]
        [Display(Name = "Last Name")]
        public string LastName { get; set; }

        [Required]
        [Display(Name = "Email Address")]
        [DataType(DataType.EmailAddress)]
        public string EmailID { get; set; }

        [Required]
        [Display(Name = "Password")]
        [DataType(DataType.Password)]
        public string Password { get; set; }

        [Required]
        [Display(Name = "Confirm Password")]
        [DataType(DataType.Password)]
        public string ConfirmPassword { get; set; }

        [DataType(DataType.Date)]
        [Display(Name = "Date Of Birth")]
        public string DOB { get; set; }

        public bool SignUp(ModelStateDictionary modelState)
        {
            if (modelState.IsValid)
            {
                if (Password != ConfirmPassword)
                {
                    modelState.AddModelError("", "Password and Confirm Password do not match!");
                    return false;
                }


                if (1 == 0)
                {
                    modelState.AddModelError("", "Email Address already exists!");
                    return false;
                }

                return true;
            }

            return false;
        }

    }
}
